﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Event_SG_EWDT
{
    public class NotificationControl
    {
        public static string CreateNotification(int sender, int reciever, string notification, DateTime time)
        {
            Notification n = new Notification();
            n.NotificationContent = notification;
            n.sender = sender.ToString();
            n.receiver = reciever.ToString();
            n.time = time;
            n.Notice_id = DBMANAGER.CreateNotification(n);

            return n.Notice_id;
        }

        public static List<Notification> RetrieveNotification(string my_membership_no)
        {
            return DBMANAGER.RetrieveMyNotification(my_membership_no);
        }

        public static int NoOfUnreadMessage(string member_no)
        {
            return DBQUERIES.NoOfUnreadNotification(member_no).Count;
        }
        public static int MessageAreRead(string member_id)
        {
           return DBQUERIES.UpdateNotificationTORead(member_id);
        }

        public static List<Member> MemberFromGroup(string groupid)
        {
            return DBMANAGER.RetrieveGroupMember_NotAdmin(groupid);
        }
        public static List<Member> AdminFromGroup(string groupid)
        {
            return DBMANAGER.RetrieveGroupMember_OnlyAdmin(groupid);
        }
        public static List<Member> MemberFromEvent(string eventid)
        {
            return DBMANAGER.RetrieveEventMember_NotAdmin(eventid);
        }
        public static List<Member> AdminFromEvent(string eventid)
        {
            return DBMANAGER.RetrieveEventMember_OnlyAdmin(eventid);
        }
        
    }
}